﻿@page "/customers/search"
@inherits FluxorComponent;
@using FluxorBlazorWeb.ActionSubscriberTutorial.Client.Store
@using FluxorBlazorWeb.ActionSubscriberTutorial.Client.Store.CustomerUseCases.SearchUseCases

<h3>Search</h3>
@if (!State.Value.Customers.Any())
{
    if (State.Value.IsLoading)
    {
        <h4>Loading...</h4>
    }
    else
    {
        <p>No customers found.</p>
    }
}
else
{
    <button type="button" class="btn btn-secondary" @onclick=Refresh>Refresh</button>
    <table class="table table-striped">
        <thead>
            <tr>
                <th scope="col">&nbsp;</th>
                <th scope="col">Id</th>
                <th scope="col">Name</th>
            </tr>
        </thead>
        <tbody>
            @foreach (Customer customer in State.Value.Customers)
            {
                <tr>
                    <th scope="row" class="col-1"><a href='/customer/edit/@customer.Id'>Edit</a></th>
                    <td>@customer.Id</td>
                    <td>@customer.Name</td>
                </tr>
            }
        </tbody>
    </table>
}


